//
//  NSObject+DeepMutableCopy.m
//  SulitLoan
//
//  Created by 虞嘉伟 on 2025/2/28.
//  
  

#import "NSObject+DeepMutableCopy.h"

@implementation NSObject (DeepMutableCopy)

@end



@implementation NSDictionary (DeepMutableCopy)

- (id)deepMutableCopy {
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    for (id key in self.allKeys) {
        id value = self[key];
        if ([value respondsToSelector:@selector(deepMutableCopy)]) {
            mutableDict[key] = [value deepMutableCopy];
        } else {
            mutableDict[key] = value;
        }
    }
    return mutableDict;
}

@end

@implementation NSArray (DeepMutableCopy)

- (id)deepMutableCopy {
    NSMutableArray *mutableArray = [NSMutableArray array];
    for (id value in self) {
        if ([value respondsToSelector:@selector(deepMutableCopy)]) {
            [mutableArray addObject:[value deepMutableCopy]];
        } else {
            [mutableArray addObject:value];
        }
    }
    return mutableArray;
}

@end
